/// @tags: BinaryIndexedArray
#include <cstdio>
#include <iostream>

using namespace std;

namespace BlueQuantum {

int constexpr N = 2.05e3;

int n, m;

struct BinaryIndexedArray {
  int a[N][N];

  inline static int lowbit(int x) { return x & -x; }

  inline void modify(int x, int y, int v) {
    for (int i = x; i <= n; i += lowbit(i)) {
      for (int j = y; j <= m; j += lowbit(j)) {
        a[i][j] += v;
      }
    }
  }

  inline int query(int x, int y) {
    int res = 0;
    for (int i = x; i; i -= lowbit(i)) {
      for (int j = y; j; j -= lowbit(j)) {
        res += a[i][j];
      }
    }
    return res;
  }
} b1, b2, b3, b4;

inline void modify(int x, int y, int val) {
  b1.modify(x, y, val);
  b2.modify(x, y, val * x);
  b3.modify(x, y, val * y);
  b4.modify(x, y, val * x * y);
}

inline void modify(int x, int y, int _x, int _y, int val) {
  modify(x, y, val);
  modify(x, _y + 1, -val);
  modify(_x + 1, y, -val);
  modify(_x + 1, _y + 1, val);
}

inline int query(int x, int y) {
  int res = 0;
  res += b1.query(x, y) * (x + 1) * (y + 1);
  res -= b2.query(x, y) * (y + 1);
  res -= b3.query(x, y) * (x + 1);
  res += b4.query(x, y);
  return res;
}

inline int query(int x, int y, int _x, int _y) {
  int res = 0;
  res += query(x - 1, y - 1);
  res -= query(_x, y - 1);
  res -= query(x - 1, _y);
  res += query(_x, _y);
  return res;
}

inline int main() {
  char opt;
  cin >> opt >> n >> m;
  for (int i = 1, a, b, c, d, delta; true; ++i) {
    cin >> opt >> a >> b >> c >> d;
    if (cin.eof()) return 0;
    switch (opt) {
      case 'L':
        cin >> delta;
        modify(a, b, c, d, delta);
        break;
      case 'k':
        cout << query(a, b, c, d) << '\n';
    }
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P4514 上帝造题的七分钟.in", "r", stdin);
  freopen("P4514 上帝造题的七分钟.out", "w", stdout);
#endif
#endif

  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
